<template>
    <div class="pack">
<!--        <div class="tree_container">
            <h3>机构列表</h3>
            <div class="treePack">
                <Tree :data="organizationTreeData" @on-select-change="organizationTreeChange"></Tree>
            </div>
        </div>-->
        <div class="detail_container">
            <h3>火警任务管理</h3>
            <div class="hunttool">
                <Select v-model="searchDatalist.taskListType" clearable  @on-change="searchTaskListType" placeholder="选择任务类型" size="small" style="width:150px;float: left;margin-right: 6px;">
                    <Option v-for="item in taskListTypeData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                </Select>
                <Button type="primary" icon="ios-search" size="small" @click="searchData">查询</Button>
                <Button type="ghost" icon="ios-trash-outline" size="small" class="deltebtn" @click="batchDelete">批量删除</Button>
                <Button type="ghost" icon="ios-plus-empty" size="small" class="addbtn" @click="addNew">发布任务</Button>
            </div>
            <div class="compile">
                <Table stripe border :columns="columns" :data="tabledata" @on-selection-change="compileSelect"></Table>
            </div>
            <div class="page_container">
                <Page :current="pageNo" :total="totalCount" size="small" simple class="page_btn"
                      @on-change="pageChange"></Page>
                <P class="page_text">共{{totalCount}}条</P>
            </div>
            <!--新增、修改弹出框-->
            <Modal v-model="addduty" title="编辑任务单" :closable="false" :mask-closable="false" width="800">
                <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="125" style="margin-right: 20px">
                    <Card class="right-card" dis-hover>
                        <p slot="title">任务单信息</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="任务类型" prop="taskListType">
                                <Select v-model="formValidate.taskListType" clearable  @on-change="taskListTypeChange">
                                    <Option v-for="item in taskListTypeData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="发送单位" prop="departmentName1">
                            <CheckboxGroup v-model="formValidate.departmentName1"  @on-change="checkboxChange">
                                <Checkbox v-for="item in codeForTask" :label="item.departmentName"  :key="item.value"></Checkbox>
                            </CheckboxGroup>
                        </Form-item>
                    </Card>
                    <!--火警任务单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList1">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="接警时间" prop="vaildTime">
                                <Date-picker type="datetime" placeholder="选择开始日期" v-model="formValidate.vaildTime" @on-change="vaildTimeChange"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="3">
                                <Button type="info" :loading="loading1" style="margin-left: 5px" @click="upalarmTime">更新</Button>
                            </Col>
                            <Col span="10">
                            <Form-item label="报警电话" prop="alarmPhone">
                                <Input v-model="formValidate.alarmPhone" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="气象信息" prop="weather">
                                <Input v-model="formValidate.weather" readonly placeholder=""></Input>
                            </Form-item>
                            </Col>
                            <Col span="4">
                            <Button type="info" :loading="loading2" style="margin-left: 5px" @click="upWeather">更新</Button>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="火灾地点" prop="fireAddress">
                                <Select v-model="formValidate.fireAddress" clearable >
                                    <Option v-for="item in fireAddressData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                            <Col span="10" offset="3">
                            <Form-item label="火灾类型" prop="fireType">
                                <Select v-model="formValidate.fireType" clearable >
                                    <Option v-for="item in fireTypeData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="详细地址" prop="fireAddress1">
                            <Input v-model="formValidate.fireAddress1" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="详细介质" prop="fireType1">
                            <Input v-model="formValidate.fireType1" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="出动车辆" prop="useTruck">
                            <Input v-model="formValidate.useTruck" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="现场处置情况" prop="localeSituation">
                            <Input v-model="formValidate.localeSituation" type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--救援任务单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList2">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="接警时间" prop="vaildTime">
                                <Date-picker type="datetime" placeholder="选择开始日期" v-model="formValidate.vaildTime" @on-change="vaildTimeChange"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="3">
                            <Button type="info" :loading="loading1" style="margin-left: 5px" @click="upalarmTime">更新</Button>
                            </Col>
                            <Col span="10">
                            <Form-item label="报警电话" prop="alarmPhone">
                                <Input v-model="formValidate.alarmPhone" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="气象信息" prop="weather">
                                <Input v-model="formValidate.weather" readonly placeholder=""></Input>
                            </Form-item>
                            </Col>
                            <Col span="4">
                            <Button type="info" :loading="loading2" style="margin-left: 5px" @click="upWeather">更新</Button>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="救援地点" prop="rescueLocation">
                                <Select v-model="formValidate.rescueLocation" clearable >
                                    <Option v-for="item in rescueAddressData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                            <Col span="10" offset="3">
                            <Form-item label="救援类型" prop="rescueType">
                                <Select v-model="formValidate.rescueType" clearable >
                                    <Option v-for="item in rescueTypeData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="详细地址" prop="rescueLocation1">
                            <Input v-model="formValidate.rescueLocation1" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="其它救援" prop="rescueType1">
                            <Input v-model="formValidate.rescueType1" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="出动车辆" prop="useTruck">
                            <Input v-model="formValidate.useTruck" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="现场处置情况" prop="localeSituation">
                            <Input v-model="formValidate.localeSituation" type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--生产监护任务单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList3">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="调度时间" prop="vaildTime">
                                <Date-picker type="datetime" placeholder="选择开始日期" v-model="formValidate.vaildTime" @on-change="vaildTimeChange"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="3">
                            <Button type="info" :loading="loading1" style="margin-left: 5px" @click="upalarmTime">更新</Button>
                            </Col>
                            <Col span="10">
                            <Form-item label="调度电话" prop="alarmPhone">
                                <Input v-model="formValidate.alarmPhone" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="气象信息" prop="weather">
                                <Input v-model="formValidate.weather" readonly placeholder=""></Input>
                            </Form-item>
                            </Col>
                            <Col span="4">
                            <Button type="info" :loading="loading2" style="margin-left: 5px" @click="upWeather">更新</Button>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="监护地点" prop="custodyPlace">
                                <Select v-model="formValidate.custodyPlace" clearable >
                                    <Option v-for="item in custodyAddressData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                            <Col span="10" offset="3">
                            <Form-item label="监护类型" prop="custodyType">
                                <Select v-model="formValidate.custodyType" clearable >
                                    <Option v-for="item in custodyTypeData" :value="item.value" :key="item.value" >{{item.value }}</Option>
                                </Select>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="详细地址" prop="custodyPlace1">
                            <Input v-model="formValidate.custodyPlace1" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="其它监护" prop="custodyType1">
                            <Input v-model="formValidate.custodyType1" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="出动车辆" prop="useTruck">
                            <Input v-model="formValidate.useTruck" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="现场处置情况" prop="localeSituation">
                            <Input v-model="formValidate.localeSituation" type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--会议通知单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList4">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="通知时间" prop="vaildTime">
                                <Date-picker type="datetime" placeholder="选择开始日期" v-model="formValidate.vaildTime" @on-change="vaildTimeChange"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="3">
                            <Button type="info"  :loading="loading1" style="margin-left: 5px" @click="upalarmTime">更新</Button>
                            </Col>
                        </Row>
                        <Form-item label="会议通知人" prop="conferenceNotifier">
                            <Input v-model="formValidate.conferenceNotifier" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="会议地点" prop="conferencePlace">
                            <Input v-model="formValidate.conferencePlace" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="会议内容及相关要求" prop="conferenceContent">
                            <Input v-model="formValidate.conferenceContent" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="参加人员" prop="attendee">
                            <Input v-model="formValidate.attendee" type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--战备任务通知单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList5">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="通知时间" prop="vaildTime">
                                <Date-picker type="datetime" placeholder="选择开始日期" v-model="formValidate.vaildTime" @on-change="vaildTimeChange"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="3">
                            <Button type="info"  :loading="loading1" style="margin-left: 5px" @click="upalarmTime">更新</Button>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="任务发布人" prop="taskPublisher">
                                <Input v-model="formValidate.taskPublisher" placeholder=""></Input>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="任务接收人" prop="taskSendee">
                                <Input v-model="formValidate.taskSendee" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="任务内容" prop="taskContent">
                            <Input v-model="formValidate.taskContent" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="注意事项" prop="attention">
                            <Input v-model="formValidate.attention" type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                </Form>
                <div slot="footer">
                    <Button type="ghost" @click="compileCancel()">取消</Button>
                    <Button type="primary" :loading="compileSubmitloading" @click="compileSubmit('formValidate')">发送任务</Button>
                </div>
            </Modal>

            <!--查看-->
            <Modal v-model="addduty1" title="查看任务单" :closable="false" :mask-closable="false" width="800">
                <Form   :label-width="125" style="margin-right: 20px">
                    <Card class="right-card" dis-hover>
                        <p slot="title">任务单信息</p>
                        <Row>
                            <Col span="12">
                            <Form-item label="发送单位：" prop="" :label-width="100">
                                <p>{{formValidate.sent}}</p>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="任务类型：" prop="" :label-width="100">
                                <p>{{formValidate.taskListType}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="已接单位：" prop="" :label-width="100">
                                <p>{{formValidate.isMove}}</p>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="未接单位：" prop="" :label-width="100">
                                <p>{{formValidate.notMove}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                    </Card>
                    <!--火警任务单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList1">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="接警时间：" prop="">
                                <p>{{formValidate.vaildTime}}</p>
                            </Form-item>
                            </Col>
                            <Col span="10">
                            <Form-item label="报警电话：" prop="">
                                <p>{{formValidate.alarmPhone}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="气象信息：" prop="">
                                <p>{{formValidate.weather}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="火灾地点：" prop="">
                            <Input v-model="formValidate.fireAddress" readonly type="textarea" :autosize="{minRows: 2,maxRows: 8}" ></Input>
                        </Form-item>
                        <Form-item label="火灾类型：" prop="">
                            <Input v-model="formValidate.fireType" readonly type="textarea" :autosize="{minRows: 2,maxRows: 8}" ></Input>
                        </Form-item>
                        <Form-item label="出动车辆：" prop="">
                            <Input v-model="formValidate.useTruck" readonly type="textarea" :autosize="{minRows: 2,maxRows: 8}" ></Input>
                        </Form-item>
                        <Form-item label="现场处置情况：" prop="">
                            <Input v-model="formValidate.localeSituation" readonly type="textarea" :autosize="{minRows: 2,maxRows: 8}" ></Input>
                        </Form-item>
                    </Card>
                    <!--救援任务单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList2">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="接警时间：" prop="">
                                <p>{{formValidate.vaildTime}}</p>
                            </Form-item>
                            </Col>
                            <Col span="10">
                            <Form-item label="报警电话：" prop="">
                                <p>{{formValidate.alarmPhone}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="气象信息：" prop="">
                                <p>{{formValidate.weather}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="救援地点：" prop="">
                            <Input v-model="formValidate.rescueLocation" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="救援类型：" prop="">
                            <Input v-model="formValidate.rescueType" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="出动车辆：" prop="">
                            <Input v-model="formValidate.useTruck" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="现场处置情况：" prop="">
                            <Input v-model="formValidate.localeSituation" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--生产监护任务单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList3">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="调度时间：" prop="">
                                <p>{{formValidate.vaildTime}}</p>
                            </Form-item>
                            </Col>
                            <Col span="10">
                            <Form-item label="调度电话：" prop="">
                                <p>{{formValidate.alarmPhone}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="10">
                            <Form-item label="气象信息：" prop="">
                                <p>{{formValidate.weather}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="监护地点：" prop="">
                            <Input v-model="formValidate.custodyPlace" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="监护类型：" prop="">
                            <Input v-model="formValidate.custodyType" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="出动车辆：" prop="">
                            <Input v-model="formValidate.useTruck" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="现场处置情况：" prop="localeSituation">
                            <Input v-model="formValidate.localeSituation" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--会议通知单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList4">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="通知时间：" prop="">
                                <p>{{formValidate.vaildTime}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="会议通知人：" prop="">
                            <Input v-model="formValidate.conferenceNotifier" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="会议地点：" prop="">
                            <Input v-model="formValidate.conferencePlace" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="会议内容及相关要求：" readonly prop="">
                            <Input v-model="formValidate.conferenceContent" type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="参加人员：" prop="">
                            <Input v-model="formValidate.attendee" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                    <!--战备任务通知单-->
                    <Card class="right-card" dis-hover  v-if="isTaskList.taskList5">
                        <p slot="title">任务单内容</p>
                        <Row>
                            <Col span="10">
                            <Form-item label="通知时间：" prop="">
                                <p>{{formValidate.vaildTime}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="任务发布人：" prop="">
                                <p>{{formValidate.taskPublisher}}</p>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="任务接收人：" prop="">
                                <p>{{formValidate.taskSendee}}</p>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="任务内容：" prop="">
                            <Input v-model="formValidate.taskContent" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                        <Form-item label="注意事项：" prop="">
                            <Input v-model="formValidate.attention" readonly type="textarea" :rows="2" ></Input>
                        </Form-item>
                    </Card>
                </Form>
                <div slot="footer">
                    <Button type="primary" @click="compileCancel()">关闭</Button>
                </div>
            </Modal>
        </div>
    </div>
</template>
<script type="text/javascript">
    var ezjsUtil = Vue.ezjsUtil;
    var apiConstants = ezjsUtil.constants.api;
    export default {
        components: {},
        data() {
            const validatevaildTime = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请选择日期'));
                } else {
                    callback();
                }
            };
            return {
                departmentName:CURRENT_LEADER.departmentName,  //登录人员机构名
                departmentCode:CURRENT_LEADER.departmentCode,  //登录人员机构code值
                loading1:false,
                loading2:false,
                compileSubmitloading:false,
                //任务单类型下拉
                taskListTypeData:'',
                fireAddressData:'',
                fireTypeData:'',
                rescueAddressData:'',
                rescueTypeData:'',
                custodyAddressData:'',
                custodyTypeData:'',
                //二级机构code
                codeForTask:'',
                //任务单类型表
                isTaskList:{
                    taskList1:true,
                    taskList2:false,
                    taskList3:false,
                    taskList4:false,
                    taskList5:false,
                },
                //机构树
                organizationTreeData:[],
                //新增值班显示
                addduty: false,
                addduty1: false,
                conditionModal: false,
                //记录批量删除id
                compiledele: "",
                //当前页
                pageNo: 1,
                //总共多少页
                totalPage: '',
                //表格总共记录数
                totalCount: 0,
                searchDatalist:{
                    taskListType:'',
                },
                //表格头部信息
                columns: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        type: 'index',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '任务类型',
                        key: 'taskListType',
                        align: 'center',
                    },
                    {
                        title: '发布日期',
                        key: 'publishTime',
                        align: 'center',
                    },
                    {
                        title: '执行状态',
                        key: 'vaild',
                        align: 'center',
                        render: (h, params) => {
                            const row = params.row;
                            const color = row.vaild === -1 ? 'green' : row.vaild === 1 ? 'red' : 'blue';
                            const text = row.vaild === -1 ? '已接警' : row.vaild === 1 ? '未接警' : '接警中';
                            return h('Tag', {
                                props: {
                                    type: 'dot',
                                    color: color
                                }
                            }, text);
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width: 220,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.taskListIsMove(params.row.id);
                                            this.taskListTypeChange(params.row.taskListType);
                                            this.addduty1=true;
                                            this.examineDate(params.row);
                                        }
                                    }
                                }, '查看'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteList(params.row.id);
                                        }
                                    }
                                }, '删除'),
                            ]);
                        }
                    }
                ],
                //表格数据
                tabledata: [],
                //新增表单
                formValidate: {
                    id:'',
                    departmentNameForTask:'',
                    departmentCodeForTask:'',
                    departmentName1:[],
                    vaildTime:'',       //接警时间/通知时间
                    alarmPhone:'',      //接警电话
                    fireAddress:'龙凤',     //火灾地点
                    fireAddress1:'',
                    fireType:'A',        //火灾类型
                    fireType1:'',
                    weather:'',     //气象信息
                    rescueLocation:'龙凤',      //救援地点
                    rescueType:'车辆事故',      //救援类型
                    rescueLocation1:'',
                    rescueType1:'',
                    custodyPlace:'化工区',        //监护地点
                    custodyType:'动火监护',     //监护类型
                    custodyPlace1:'',
                    custodyType1:'',
                    conferenceNotifier:'',      //会议通知人
                    conferencePlace:'',     //会议地点
                    conferenceContent:'',       //会议内容
                    attendee:'',        //参加人员
                    taskPublisher:'',       //任务发起人
                    taskSendee:'',      //任务接收人
                    taskContent:'',     //任务内容
                    attention:'',       //注意事项
                    taskListType:'火警任务单',       //任务类别
                    useTruck:'',        //出动车辆
                    localeSituation:'',     //现场处置情况
                    sent:'',     //查看发送单位
                    isMove:'',     //查看已接单位
                    notMove:'',     //查看未接单位
                },
                //表单验证
                ruleValidate: {
                    departmentName1:[
                        { required: true, type: 'array', min: 1, message: '至少选择一个单位', trigger: 'change' },
                    ],
                    taskListType:[
                        {required: true, message: '请选择任务类型', trigger: 'change'}
                    ],
                    fireAddress: [
                        {required: true, message: '请选择火灾地点', trigger: 'change'}
                    ],
                    fireType: [
                        {required: true, message: '请选择火灾类型', trigger: 'change'}
                    ],
                    rescueLocation: [
                        {required: true, message: '请选择救援地点', trigger: 'change'}
                    ],
                    rescueType: [
                        {required: true, message: '请选择救援类型', trigger: 'change'}
                    ],
                    custodyPlace: [
                        {required: true, message: '请选择监护地点', trigger: 'change'}
                    ],
                    custodyType: [
                        {required: true, message: '请选择监护类型', trigger: 'change'}
                    ],
                    vaildTime: [
                        {required: true, validator: validatevaildTime, trigger: 'change'}
                    ],
                    fireAddress1: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    fireType1: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    rescueLocation1: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    rescueType1: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    custodyPlace1: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    custodyType1: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    useTruck: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    localeSituation: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    conferenceNotifier: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    conferencePlace: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    conferenceContent: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    attendee: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    taskContent: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                    attention: [
                        { type: 'string', max: 200, message: '内容过长，最多200字', trigger: 'blur' }
                    ],
                },


            }
        },
        computed: {},
        created() {
            this.flipList();
            this.organizationFlipList();
            this.dictionary_flipList_taskListType();
            this.dictionary_flipList_fireAddress();
            this.dictionary_flipList_fireType();
            this.dictionary_flipList_rescueAddress();
            this.dictionary_flipList_rescueType();
            this.dictionary_flipList_custodyAddress();
            this.dictionary_flipList_custodyType();
            this.taskListGetSecondDepartment();
        },
        methods: {
            vaildTimeChange(date){
                this.formValidate.vaildTime = date;
            },
            //日期格式转换
            dateformatting(dateval) {
                var newTime = new Date(dateval);
                var yyyy = newTime.getFullYear();
                var MM = newTime.getMonth() + 1;
                var dd = newTime.getDate();
                var hh = newTime.getHours();
                var mm = newTime.getMinutes();
                var ss = newTime.getSeconds();
                var time = yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
//                var time = yyyy + "-" + MM + "-" + dd;
                return time
            },
            //机构树点击事件
            organizationTreeChange(val){
                if(this.addduty){
                    if(val.length>0){
                        this.formValidate.departmentName=val[0].fullTitle;
                        this.formValidate.departmentCode=val[0].code;
                        this.searchData();
                    }else {
                        this.formValidate.departmentCode='';
                        this.formValidate.departmentName='';
                        this.searchData();
                    }
                }else if(val.length>0){
                    this.formValidate.departmentName=val[0].fullTitle;
                    this.formValidate.departmentCode=val[0].code;
                }else {
                    this.formValidate.departmentCode='';
                    this.formValidate.departmentName='';
                }
            },
            //发送任务单位
            checkboxChange(val){
                var newarry=[];
                for(var i=0;i<val.length;i++){
                    for(var n=0;n<this.codeForTask.length;n++){
                        if(val[i]==this.codeForTask[n].departmentName){
                            newarry.push(this.codeForTask[n].departmentCode);
                        }
                    }
                }
                this.formValidate.departmentCodeForTask=newarry.join(',');
                this.formValidate.departmentNameForTask=this.formValidate.departmentName1.join(',');
            },
            //任务类型
            taskListTypeChange(val){
                this.compileReset('formValidate')
                this.isTaskList.taskList1=false;
                this.isTaskList.taskList2=false;
                this.isTaskList.taskList3=false;
                this.isTaskList.taskList4=false;
                this.isTaskList.taskList5=false;
                switch (val)
                {
                    case '火警任务单':
                        this.isTaskList.taskList1=true;
                        break;
                    case '救援任务单':
                        this.isTaskList.taskList2=true;
                        break;
                    case '生产监护任务单':
                        this.isTaskList.taskList3=true;
                        break;
                    case '会议通知单':
                        this.isTaskList.taskList4=true;
                        break;
                    case '战备任务通知单':
                        this.isTaskList.taskList5=true;
                        break;
                }
                this.formValidate.taskListType=val;
            },
            //查询
            searchData(){
                this.pageNo=1;
                this.flipList();
            },
            searchTaskListType(val){
                this.searchDatalist.taskListType=val;
            },
            //新增
            addNew() {
                this.upalarmTime();
                this.upWeather();
                this.addduty = true;
                this.formValidate.id = "";
//                this.compile = true;
            },

            //查看
            examineDate(val) {
                this.formValidate.id=val.id;
                this.formValidate.departmentNameForTask=val.departmentNameForTask;
                this.formValidate.departmentCodeForTask=val.departmentCodeForTask;
                this.formValidate.departmentName=val.departmentName;
                this.formValidate.departmentCode=val.departmentCode;
                this.formValidate.vaildTime=val.vaildTime;
                this.formValidate.alarmPhone=val.alarmPhone;
                this.formValidate.fireAddress=val.fireAddress;
                this.formValidate.fireType=val.fireType;
                this.formValidate.weather=val.weather;
                this.formValidate.rescueLocation=val.rescueLocation;
                this.formValidate.rescueType=val.rescueType;
                this.formValidate.custodyPlace=val.custodyPlace;
                this.formValidate.custodyType=val.custodyType;
                this.formValidate.conferenceNotifier=val.conferenceNotifier;
                this.formValidate.conferencePlace=val.conferencePlace;
                this.formValidate.conferenceContent=val.conferenceContent;
                this.formValidate.attendee=val.attendee;
                this.formValidate.taskPublisher=val.taskPublisher;
                this.formValidate.taskSendee=val.taskSendee;
                this.formValidate.taskContent=val.taskContent;
                this.formValidate.attention=val.attention;
                this.formValidate.taskListType=val.taskListType;
                this.formValidate.useTruck=val.useTruck;
                this.formValidate.localeSituation=val.localeSituation;
                this.formValidate.sent=val.sent;
            },
            //修改
            amend(val) {
            },


            //表格勾选
            compileSelect(selection, row) {
                var ids=[];
                for (var i=0;i<selection.length;i++){
                    ids.push(selection[i].id);
                }
                this.compiledele=ids.join(',');
            },
            //批量删除
            batchDelete() {
                if(this.compiledele) {
                    this.deleteList(this.compiledele);
                }else {
                    this.$Message.error('请选择删除项!');
                }
            },

            //表单取消
            compileCancel() {
                this.addduty=false;
                this.addduty1=false;
                this.compileReset('formValidate');
            },

            //表单重置
            compileReset(name) {
                this.$refs[name].resetFields();
            },

            //分页改变时
            pageChange(val) {
                if (val <= this.totalPage) {
                    this.pageNo = val;
                    this.flipList();
                }
            },

            //获取系统时间
            upalarmTime(){
                var _this = this;
                _this.loading1=true;
                ezjsUtil.request(apiConstants.taskList_getCurrentDate,
                    {
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.formValidate.vaildTime=_this.dateformatting(data);
                        _this.loading1=false;
                    }
                )
            },
            //获取二级机构code
            taskListGetSecondDepartment(){
                var _this = this;
                ezjsUtil.request(apiConstants.taskList_getSecondDepartment,
                    {  },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.codeForTask=data;
                    }
                )
            },
            //获取天气信息
            upWeather(){
                var _this = this;
                _this.loading2=true;
                ezjsUtil.request(apiConstants.taskList_getWeather,
                    {
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.formValidate.weather=data;
                        _this.loading2=false;
                    }
                )
            },
            //新增,修改大队值班提交
            compileSubmit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        var _this = this;
                        _this.compileSubmitloading=true;
                        ezjsUtil.request(apiConstants.taskList_edit,
                            {
                                id: _this.formValidate.id,
                                departmentNameForTask: _this.formValidate.departmentNameForTask,
                                departmentCodeForTask: _this.formValidate.departmentCodeForTask,
                                departmentName:_this.departmentName,
                                departmentCode:_this.departmentCode,
                                vaildTime: _this.formValidate.vaildTime,
                                alarmPhone: _this.formValidate.alarmPhone,
                                fireAddress: _this.formValidate.fireAddress+_this.formValidate.fireAddress1,
                                fireType: _this.formValidate.fireType+_this.formValidate.fireType1,
                                weather: _this.formValidate.weather,
                                rescueLocation: _this.formValidate.rescueLocation+ _this.formValidate.rescueLocation1,
                                rescueType: _this.formValidate.rescueType+ _this.formValidate.rescueType1,
                                custodyPlace: _this.formValidate.custodyPlace+ _this.formValidate.custodyPlace1,
                                custodyType: _this.formValidate.custodyType+ _this.formValidate.custodyType1,
                                conferenceNotifier: _this.formValidate.conferenceNotifier,
                                conferencePlace: _this.formValidate.conferencePlace,
                                conferenceContent: _this.formValidate.conferenceContent,
                                attendee: _this.formValidate.attendee,
                                taskPublisher: _this.formValidate.taskPublisher,
                                taskSendee: _this.formValidate.taskSendee,
                                taskContent: _this.formValidate.taskContent,
                                attention: _this.formValidate.attention,
                                taskListType: _this.formValidate.taskListType,
                                useTruck: _this.formValidate.useTruck,
                                localeSituation: _this.formValidate.localeSituation,
                            },
                            function (err, data) {
                                if (err) {
                                    return;
                                }
                                _this.pageNo = 1;
                                _this.flipList();
                                _this.organizationFlipList();
                                _this.compileSubmitloading=false;
                                _this.addduty = false;
                                _this.$Message.success('提交成功!');
                                _this.compileReset('formValidate');
                            }
                        )
                    } else {
                        this.$Message.error('表单验证失败!');
                    }
                })
            },

            //查询列表
            flipList() {
                var _this = this;
                ezjsUtil.request(apiConstants.taskList_flipList,
                    {
                        taskListType:_this.searchDatalist.taskListType,
                        departmentCode:'',
                        pageNo: _this.pageNo
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.tabledata = data.listInfo;
                        _this.totalCount = data.flipInfo.totalCount;
                        _this.totalPage = data.flipInfo.totalPage;
                    }
                )
            },

            //删除
            deleteList(delid) {
                var _this = this;
                ezjsUtil.request(apiConstants.taskList_removeByIds,
                    {
                        ids: delid
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.compiledele='';
                        _this.flipList();
                    }
                )
            },

            //任务单位是否接警
            taskListIsMove(val) {
                var _this = this;
                ezjsUtil.request(apiConstants.taskList_isMove,
                    {
                        id:val
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.formValidate.isMove=data.isMove;
                        _this.formValidate.notMove=data.notMove;
                    }
                )
            },

            //获取所有组织机构树
            organizationFlipList() {
                var _this = this;
                ezjsUtil.request(apiConstants.organization_flipList,
                    { },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.organizationTreeData=data;
                        _this.organizationTreeData[0].expand=true;
                    }
                )
            },

            /*字典数据相关接口*/
            dictionary_flipList_taskListType() { //查询火警任务单
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "taskListType",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.taskListTypeData = data;
                    }
                )
            },
            dictionary_flipList_fireAddress() { //火灾地点
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "fireAddress",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.fireAddressData = data;
                    }
                )
            },
            dictionary_flipList_fireType() { //火灾类型
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "fireType",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.fireTypeData = data;
                    }
                )
            },
            dictionary_flipList_rescueAddress() { //救援地点
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "rescueAddress",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.rescueAddressData = data;
                    }
                )
            },
            dictionary_flipList_rescueType() { //救援类型
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "rescueType",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.rescueTypeData = data;
                    }
                )
            },
            dictionary_flipList_custodyAddress() { //监护地点
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "custodyAddress",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.custodyAddressData = data;
                    }
                )
            },
            dictionary_flipList_custodyType() { //监护类型
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "custodyType",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.custodyTypeData = data;
                    }
                )
            },
        },
        mounted() {
        }
    }
</script>
<style lang="less" scoped>
    .pack {
        width: 100%;
        height: 100%;
    }

    .tree_container {
        width: 260px;
        height: 100%;
        float: left;
        border: 1px solid #d3d8e0;

    h3 {
        line-height: 40px;
        text-align: center;
        font-size: 14px;
        color: #6e6d6d;
    }
    .treePack{
        height: 94%;
        padding: 10px;
        overflow: auto;
    }
    }
    .detail_container {
        height: 100%;
        /*margin-left: 280px;*/
        overflow: hidden;
        overflow-y: auto;
    }

    h3 {
        height: 40px;
        line-height: 40px;
        border-bottom: 1px solid #d3d8e0;
    }

    .hunttool, .hunttoolreturn {
        height: 54px;
        padding: 15px 0;

    .addbtn {
        margin-right: 6px;
        float: right;
    }

    .deltebtn {
        margin-right: 6px;
        float: right;
    }

    }
    .hunt {
        width: 14rem;
    }

    .page_container {
        height: 30px;
        margin-top: 20px;

    .page_btn {
        float: right;
    }

    .page_text {
        float: right;
        line-height: 26px;
    }

    }

    .right-card {
        margin-bottom: 20px;
    }
</style>